bug # 2030968  	[NJ-1434] hardcoded values in mp4a atom in the composer
diff --git a/fileformats/mp4/composer/include/a_atomdefs.h b/fileformats/mp4/composer/include/a_atomdefs.h
index fd093cf..b6e016b 100644
--- a/fileformats/mp4/composer/include/a_atomdefs.h
+++ b/fileformats/mp4/composer/include/a_atomdefs.h
@@ -307,6 +307,21 @@
 
 #define DEFAULT_MOVIE_FRAGMENT_DURATION_IN_MS 10000
 
+class PVMP4FFComposerAudioEncodeParams
+{
+    public:
+        PVMP4FFComposerAudioEncodeParams()
+        {
+            samplingRate = 0;
+            numberOfChannels = 2;
+            bitsPerSample = 16;
+        }
+
+        uint32 samplingRate;
+        uint32 numberOfChannels;
+        uint32 bitsPerSample;
+};
+
 #endif
 
 
diff --git a/fileformats/mp4/composer/include/a_impeg4file.h b/fileformats/mp4/composer/include/a_impeg4file.h
index 166403d..0a78783 100644
--- a/fileformats/mp4/composer/include/a_impeg4file.h
+++ b/fileformats/mp4/composer/include/a_impeg4file.h
@@ -321,6 +321,9 @@
         virtual void setVideoParams(uint32 trackID, float frate, uint16 interval,
                                     uint32 frame_width, uint32 frame_height) = 0;
 
+        virtual void setAudioEncodeParams(uint32 trackId,
+                                          PVMP4FFComposerAudioEncodeParams &audioParams) = 0;
+
         virtual void setH263ProfileLevel(uint32 trackID,
                                          uint8 profile,
                                          uint8 level) = 0;
diff --git a/fileformats/mp4/composer/include/amrsampleentry.h b/fileformats/mp4/composer/include/amrsampleentry.h
index 4af958b..4e0bf63 100644
--- a/fileformats/mp4/composer/include/amrsampleentry.h
+++ b/fileformats/mp4/composer/include/amrsampleentry.h
@@ -64,6 +64,12 @@
             }
         }
 
+        void setAudioEncodeParams(PVMP4FFComposerAudioEncodeParams &audioParams)
+        {
+            _reserved2 = audioParams.numberOfChannels;
+            _reserved3 = audioParams.bitsPerSample;
+        }
+
     private:
         virtual void recomputeSize();
         void init();
diff --git a/fileformats/mp4/composer/include/audiosampleentry.h b/fileformats/mp4/composer/include/audiosampleentry.h
index b705c70..8d847d6 100644
--- a/fileformats/mp4/composer/include/audiosampleentry.h
+++ b/fileformats/mp4/composer/include/audiosampleentry.h
@@ -23,6 +23,7 @@
 
 #include "sampleentry.h"
 #include "esdatom.h"
+#include "a_atomdefs.h"
 
 
 class PVA_FF_AudioSampleEntry : public PVA_FF_SampleEntry
@@ -94,6 +95,12 @@
             _pes->writeMaxSampleSize(_afp);
         }
 
+        void setAudioEncodeParams(PVMP4FFComposerAudioEncodeParams &audioParams)
+        {
+            _reserved2 = audioParams.numberOfChannels;
+            _reserved3 = audioParams.bitsPerSample;
+        }
+
     private:
         virtual void recomputeSize();
         void init();
diff --git a/fileformats/mp4/composer/include/mediaatom.h b/fileformats/mp4/composer/include/mediaatom.h
index 5479da0..a91f538 100644
--- a/fileformats/mp4/composer/include/mediaatom.h
+++ b/fileformats/mp4/composer/include/mediaatom.h
@@ -142,6 +142,11 @@
             _pmediaInformation->setVideoParams(frame_width, frame_height);
         }
 
+        void setAudioEncodeParams(PVMP4FFComposerAudioEncodeParams &audioParams)
+        {
+            _pmediaInformation->setAudioEncodeParams(audioParams);
+        }
+
         void setH263ProfileLevel(uint8 profile, uint8 level)
         {
             _pmediaInformation->setH263ProfileLevel(profile, level);
diff --git a/fileformats/mp4/composer/include/mediainformationatom.h b/fileformats/mp4/composer/include/mediainformationatom.h
index ff2cfe2..bd622df 100644
--- a/fileformats/mp4/composer/include/mediainformationatom.h
+++ b/fileformats/mp4/composer/include/mediainformationatom.h
@@ -130,6 +130,11 @@
             _psampleTableAtom->setVideoParams(frame_width, frame_height);
         }
 
+        void setAudioEncodeParams(PVMP4FFComposerAudioEncodeParams &audioParams)
+        {
+            _psampleTableAtom->setAudioEncodeParams(audioParams);
+        }
+
         void setH263ProfileLevel(uint8 profile, uint8 level)
         {
             _psampleTableAtom->setH263ProfileLevel(profile, level);
diff --git a/fileformats/mp4/composer/include/mpeg4file.h b/fileformats/mp4/composer/include/mpeg4file.h
index 8e1e738..b35646e 100644
--- a/fileformats/mp4/composer/include/mpeg4file.h
+++ b/fileformats/mp4/composer/include/mpeg4file.h
@@ -179,6 +179,9 @@
         virtual void setVideoParams(uint32 trackID, float frate, uint16 interval,
                                     uint32 frame_width, uint32 frame_height);
 
+        virtual void setAudioEncodeParams(uint32 trackId,
+                                          PVMP4FFComposerAudioEncodeParams &audioParams);
+
 
         virtual void setH263ProfileLevel(uint32 trackID,
                                          uint8 profile,
diff --git a/fileformats/mp4/composer/include/sampledescriptionatom.h b/fileformats/mp4/composer/include/sampledescriptionatom.h
index 0d157b3..951db96 100644
--- a/fileformats/mp4/composer/include/sampledescriptionatom.h
+++ b/fileformats/mp4/composer/include/sampledescriptionatom.h
@@ -24,6 +24,7 @@
 #ifndef __SampleDescriptionAtom_H__
 #define __SampleDescriptionAtom_H__
 
+#include "a_atomdefs.h"
 #include "fullatom.h"
 #include "sampleentry.h"
 #include "esdescriptor.h"
@@ -97,6 +98,8 @@
             _frame_height = (uint16)frame_height;
         }
 
+        void setAudioEncodeParams(PVMP4FFComposerAudioEncodeParams &audioParams);
+
         void setH263ProfileLevel(uint8 profile, uint8 level)
         {
             _h263Profile = profile;
diff --git a/fileformats/mp4/composer/include/sampletableatom.h b/fileformats/mp4/composer/include/sampletableatom.h
index 4358f8c..8f1ea8e 100644
--- a/fileformats/mp4/composer/include/sampletableatom.h
+++ b/fileformats/mp4/composer/include/sampletableatom.h
@@ -151,6 +151,11 @@
             _psampleDescriptionAtom->setVideoParams(frame_width, frame_height);
         }
 
+        void setAudioEncodeParams(PVMP4FFComposerAudioEncodeParams &audioParams)
+        {
+            _psampleDescriptionAtom->setAudioEncodeParams(audioParams);
+        }
+
         void setH263ProfileLevel(uint8 profile, uint8 level)
         {
             _psampleDescriptionAtom->setH263ProfileLevel(profile, level);
diff --git a/fileformats/mp4/composer/include/trackatom.h b/fileformats/mp4/composer/include/trackatom.h
index 37e5669..fc0a46a 100644
--- a/fileformats/mp4/composer/include/trackatom.h
+++ b/fileformats/mp4/composer/include/trackatom.h
@@ -234,6 +234,8 @@
 
         void setVideoParams(uint32 frame_width, uint32 frame_height);
 
+        void setAudioEncodeParams(PVMP4FFComposerAudioEncodeParams &audioParams);
+
         void setH263ProfileLevel(uint8 profile, uint8 level)
         {
             _pmediaAtom->setH263ProfileLevel(profile, level);
diff --git a/fileformats/mp4/composer/src/mpeg4file.cpp b/fileformats/mp4/composer/src/mpeg4file.cpp
index 2d954a7..74f65ef 100644
--- a/fileformats/mp4/composer/src/mpeg4file.cpp
+++ b/fileformats/mp4/composer/src/mpeg4file.cpp
@@ -3431,3 +3431,20 @@
     }
     return NULL;
 }
+
+void
+PVA_FF_Mpeg4File::setAudioEncodeParams(uint32 trackId,
+                                       PVMP4FFComposerAudioEncodeParams &audioParams)
+{
+    PVA_FF_TrackAtom *trackAtom;
+    trackAtom = _pmovieAtom->getMediaTrack(trackId);
+
+    if (trackAtom != NULL)
+        trackAtom->setAudioEncodeParams(audioParams);
+
+    return;
+}
+
+
+
+
diff --git a/fileformats/mp4/composer/src/sampledescriptionatom.cpp b/fileformats/mp4/composer/src/sampledescriptionatom.cpp
index fbd33bc..77ae3f1 100644
--- a/fileformats/mp4/composer/src/sampledescriptionatom.cpp
+++ b/fileformats/mp4/composer/src/sampledescriptionatom.cpp
@@ -804,3 +804,38 @@
         }
     }
 }
+
+void
+PVA_FF_SampleDescriptionAtom::setAudioEncodeParams(PVMP4FFComposerAudioEncodeParams &audioParams)
+{
+    switch (_mediaType)
+    {
+        case MEDIA_TYPE_AUDIO:
+        {
+            if (_codecType == CODEC_TYPE_AAC_AUDIO)
+            {
+                PVA_FF_AudioSampleEntry *entry = (PVA_FF_AudioSampleEntry*) getSampleEntryAt(0);
+                if (entry)
+                {
+                    entry->setAudioEncodeParams(audioParams);
+                }
+            }
+            else if (_codecType == CODEC_TYPE_AMR_AUDIO ||
+                     _codecType == CODEC_TYPE_AMR_WB_AUDIO)
+            {
+                PVA_FF_AMRSampleEntry *entry = (PVA_FF_AMRSampleEntry *)(getSampleEntryAt(0));
+                if (entry)
+                {
+                    entry->setAudioEncodeParams(audioParams);
+                }
+            }
+        }
+        default:
+            break;
+    }
+}
+
+
+
+
+
diff --git a/fileformats/mp4/composer/src/trackatom.cpp b/fileformats/mp4/composer/src/trackatom.cpp
index f2a8a4f..e05b4f4 100644
--- a/fileformats/mp4/composer/src/trackatom.cpp
+++ b/fileformats/mp4/composer/src/trackatom.cpp
@@ -503,3 +503,10 @@
     if (_pmediaAtom != NULL)
         _pmediaAtom->setVideoParams(frame_width, frame_height);
 }
+
+void
+PVA_FF_TrackAtom::setAudioEncodeParams(PVMP4FFComposerAudioEncodeParams &audioParams)
+{
+    if (_pmediaAtom != NULL)
+        _pmediaAtom->setAudioEncodeParams(audioParams);
+}
diff --git a/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_node.cpp b/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_node.cpp
index aba2351..0598f58 100644
--- a/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_node.cpp
+++ b/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_node.cpp
@@ -1806,9 +1806,16 @@
     switch (mediaType)
     {
         case MEDIA_TYPE_AUDIO:
+        {
             iMpeg4File->setTargetBitRate(trackId, config->iBitrate);
             iMpeg4File->setTimeScale(trackId, config->iTimescale);
+            PVMP4FFComposerAudioEncodeParams audioParams;
+            audioParams.numberOfChannels = config->iNumberOfChannels;
+            audioParams.samplingRate = config->iSamplingRate;
+            audioParams.bitsPerSample = config->iBitsPerSample;
+            iMpeg4File->setAudioEncodeParams(trackId, audioParams);
             break;
+        }
 
         case MEDIA_TYPE_VISUAL:
             switch (codecType)
diff --git a/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_port.cpp b/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_port.cpp
index 0c13d19..63b323d 100644
--- a/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_port.cpp
+++ b/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_port.cpp
@@ -745,6 +745,52 @@
         }
         kvp = NULL;
         numParams = 0;
+
+        // Get the sampling rate, number of channels and bits per sample for audio
+        // sampling rate
+        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.iSamplingRate = PVMF_MP4FFCN_AUDIO_SAMPLING_RATE;
+        }
+        else
+        {
+            iFormatSpecificConfig.iSamplingRate = kvp[0].value.uint32_value;
+            aConfig->releaseParameters(NULL, kvp, numParams);
+        }
+        kvp = NULL;
+        numParams = 0;
+
+        // number of channels
+        status = aConfig->getParametersSync(NULL, (PvmiKeyType)AUDIO_OUTPUT_NUM_CHANNELS_CUR_QUERY, kvp, numParams, NULL);
+        if (status != PVMFSuccess || !kvp || numParams != 1)
+        {
+            LOG_DEBUG((0, "PVMp4FFComposerPort::GetInputParametersFromPeer: Number of channels info not available. Use default"));
+            iFormatSpecificConfig.iNumberOfChannels = PVMF_MP4FFCN_AUDIO_NUM_CHANNELS;
+        }
+        else
+        {
+            iFormatSpecificConfig.iNumberOfChannels = kvp[0].value.uint32_value;
+            aConfig->releaseParameters(NULL, kvp, numParams);
+        }
+        kvp = NULL;
+        numParams = 0;
+
+        // bits per sample
+        status = aConfig->getParametersSync(NULL, (PvmiKeyType)AUDIO_OUTPUT_BITS_PER_SAMPLE_CUR_QUERY, kvp, numParams, NULL);
+        if (status != PVMFSuccess || !kvp || numParams != 1)
+        {
+            LOG_DEBUG((0, "PVMp4FFComposerPort::GetInputParametersFromPeer: Bits per sample info not available. Use default"));
+            iFormatSpecificConfig.iBitsPerSample = PVMF_MP4FFCN_AUDIO_BITS_PER_SAMPLE;
+        }
+        else
+        {
+            iFormatSpecificConfig.iBitsPerSample = kvp[0].value.uint32_value;
+            aConfig->releaseParameters(NULL, kvp, numParams);
+        }
+        kvp = NULL;
+        numParams = 0;
     }
     else if (iFormat == PVMF_MIME_H264_VIDEO_MP4 ||
              iFormat == PVMF_MIME_M4V ||
diff --git a/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_port.h b/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_port.h
index 41d09f1..4955a92 100644
--- a/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_port.h
+++ b/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_port.h
@@ -68,6 +68,11 @@
     // H263 configuration
     uint8 iH263Profile;
     uint8 iH263Level;
+
+    // Audio Encode Params
+    uint32 iNumberOfChannels;
+    uint32 iBitsPerSample;
+    uint32 iSamplingRate;
 };
 
 class PVMp4FFComposerPort : public PvmfPortBaseImpl,
diff --git a/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_tunables.h b/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_tunables.h
index d342565..beb49fa 100644
--- a/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_tunables.h
+++ b/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_tunables.h
@@ -48,7 +48,9 @@
 // Default audio track config parameters
 #define PVMF_MP4FFCN_AUDIO_BITRATE 12200
 #define PVMF_MP4FFCN_AUDIO_TIMESCALE 8000
-#define PVMF_MP4FFCN_AUDIO_NUM_CHANNELS 1
+#define PVMF_MP4FFCN_AUDIO_NUM_CHANNELS 2
+#define PVMF_MP4FFCN_AUDIO_SAMPLING_RATE 8000
+#define PVMF_MP4FFCN_AUDIO_BITS_PER_SAMPLE 16
 
 // Default text track config parameters
 #define PVMF_MP4FFCN_TEXT_BITRATE 0
diff --git a/nodes/pvomxencnode/src/pvmf_omx_enc_port.cpp b/nodes/pvomxencnode/src/pvmf_omx_enc_port.cpp
index 4f5880e..07b9ae9 100644
--- a/nodes/pvomxencnode/src/pvmf_omx_enc_port.cpp
+++ b/nodes/pvomxencnode/src/pvmf_omx_enc_port.cpp
@@ -554,6 +554,18 @@
 
         parameters[0].value.uint32_value = (uint32) iOMXNode->GetOutputNumChannels();
     }
+    else if (pv_mime_strcmp(identifier, AUDIO_OUTPUT_BITS_PER_SAMPLE_CUR_QUERY) == 0)
+    {
+        num_parameter_elements = 1;
+        status = AllocateKvp(parameters, (PvmiKeyType)AUDIO_OUTPUT_BITS_PER_SAMPLE_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;
+        }
+
+        parameters[0].value.uint32_value = (uint32) iOMXNode->iAudioInputFormat.iInputBitsPerSample;
+    }
     else if ((pv_mime_strcmp(identifier, OUTPUT_TIMESCALE_CUR_QUERY) == 0) &&
              ((iFormat == PVMF_MIME_AMR_IETF) ||
               (iFormat == PVMF_MIME_AMRWB_IETF) ||
diff --git a/pvmi/pvmf/include/pvmi_kvp.h b/pvmi/pvmf/include/pvmi_kvp.h
index 2f87198..6e0e374 100644
--- a/pvmi/pvmf/include/pvmi_kvp.h
+++ b/pvmi/pvmf/include/pvmi_kvp.h
@@ -410,6 +410,9 @@
 #define AUDIO_OUTPUT_NUM_CHANNELS_CUR_QUERY ".../num_channels;attr=cur"
 #define AUDIO_OUTPUT_NUM_CHANNELS_CUR_VALUE ".../num_channels;valtype=uint32"
 
+#define AUDIO_OUTPUT_BITS_PER_SAMPLE_CUR_QUERY ".../bits_per_sample;attr=cur"
+#define AUDIO_OUTPUT_BITS_PER_SAMPLE_CUR_VALUE ".../bits_per_sample;valtype=uint32"
+
 #define VIDEO_AVC_OUTPUT_SPS_CUR_QUERY ".../output/sps;attr=cur"
 #define VIDEO_AVC_OUTPUT_SPS_CUR_VALUE ".../output/sps;valtype=key_specific_value"