RIO-6571: changes needed for supporting progressive playback of unprotected ASF content.
diff --git a/nodes/pvdownloadmanagernode/include/pvmf_memorybufferdatastream_factory.h b/nodes/pvdownloadmanagernode/include/pvmf_memorybufferdatastream_factory.h
index cba2536..025ee7a 100644
--- a/nodes/pvdownloadmanagernode/include/pvmf_memorybufferdatastream_factory.h
+++ b/nodes/pvdownloadmanagernode/include/pvmf_memorybufferdatastream_factory.h
@@ -396,8 +396,12 @@
 
         OSCL_IMPORT_REF PvmiDataStreamStatus SetSourceRequestObserver(PvmiDataStreamRequestObserver& aObserver);
 
+        OSCL_IMPORT_REF PvmiDataStreamStatus SetBufferingCapacityAndTrimMargin(uint32 aMinCapacity, uint32 aTrimMargin);
+
         OSCL_IMPORT_REF uint32 QueryBufferingCapacity();
 
+        OSCL_IMPORT_REF uint32 QueryBufferingTrimMargin();
+
         void SourceRequestCompleted(const PVMFCmdResp& aResponse)
         {
             OSCL_UNUSED_ARG(aResponse);
@@ -516,8 +520,12 @@
 
         OSCL_IMPORT_REF PvmiDataStreamStatus MakePersistent(int32 aOffset, uint32 aSize);
 
+        OSCL_IMPORT_REF PvmiDataStreamStatus SetBufferingCapacityAndTrimMargin(uint32 aMinCapacity, uint32 aTrimMargin);
+
         OSCL_IMPORT_REF uint32 QueryBufferingCapacity();
 
+        OSCL_IMPORT_REF uint32 QueryBufferingTrimMargin();
+
         OSCL_IMPORT_REF PvmiDataStreamStatus SetReadPointerPosition(PvmiDataStreamSession aSessionID, uint32 aFilePosition);
 
 
diff --git a/nodes/pvdownloadmanagernode/src/pvmf_memorybufferdatastream_factory.cpp b/nodes/pvdownloadmanagernode/src/pvmf_memorybufferdatastream_factory.cpp
index 0b988e9..8b20ace 100644
--- a/nodes/pvdownloadmanagernode/src/pvmf_memorybufferdatastream_factory.cpp
+++ b/nodes/pvdownloadmanagernode/src/pvmf_memorybufferdatastream_factory.cpp
@@ -827,6 +827,18 @@
 }
 
 
+OSCL_EXPORT_REF PvmiDataStreamStatus PVMFMemoryBufferReadDataStreamImpl::SetBufferingCapacityAndTrimMargin(uint32 aMinCapacity, uint32 aTrimMargin)
+{
+    if (NULL == iWriteDataStream)
+    {
+        LOGERROR((0,"PVMFMemoryBufferReadDataStreamImpl::SetBufferingCapacityAndTrimMargin failed - no write data stream.\n"));
+        return PVDS_FAILURE;
+    }
+
+    return iWriteDataStream->SetBufferingCapacityAndTrimMargin(aMinCapacity, aTrimMargin);
+}
+
+
 OSCL_EXPORT_REF uint32
 PVMFMemoryBufferReadDataStreamImpl::QueryBufferingCapacity()
 {
@@ -841,6 +853,21 @@
     return capacity;
 }
 
+
+OSCL_EXPORT_REF uint32 PVMFMemoryBufferReadDataStreamImpl::QueryBufferingTrimMargin()
+{
+    uint32 margin = 0;
+
+    if (NULL != iWriteDataStream)
+    {
+        margin = iWriteDataStream->QueryBufferingTrimMargin();
+    }
+
+    LOGTRACE((0, "PVMFMemoryBufferReadDataStreamImpl::QueryBufferingTrimMargin returning %d", margin));
+    return margin;
+}
+
+
 // The data to be made persistent may be already in the temp cache.
 // If so, copy the data from temp cache into perm cache.
 // If not, when the data arrives, it is be written directly in the perm cache
@@ -2182,6 +2209,24 @@
 }
 
 
+OSCL_EXPORT_REF PvmiDataStreamStatus PVMFMemoryBufferWriteDataStreamImpl::SetBufferingCapacityAndTrimMargin(uint32 aMinCapacity, uint32 aTrimMargin)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO, (2,"PVMFMemoryBufferWriteDataStreamImpl::SetBufferingCapacityAndTrimMargin capacity=%d trim margin=%d", aMinCapacity, aTrimMargin));
+
+    /*TODO: pvmi/pvmf/include/pvmi_data_stream_interface.h
+    if( ( aMinCapacity > SOCKET_NODE_MEMPOOL_SIZE) || ( aTrimMargin > SOCKET_NODE_MEMPOOL_SIZE) ){
+        LOGERROR((0, "PVMFMemoryBufferWriteDataStreamImpl::SetBufferingCapacityAndTrimMargin failed"));
+        return PVDS_FAILURE;
+    }
+    */
+    iTempCacheCapacity = aMinCapacity;
+    iTempCacheTrimThreshold = PV_MBDS_TEMP_CACHE_TRIM_THRESHOLD_PS(iTempCacheCapacity);
+    iTempCacheTrimMargin = (MBDS_STREAM_FORMAT_SHOUTCAST == iStreamFormat) ? PV_MBDS_TEMP_CACHE_TRIM_MARGIN_SC : aTrimMargin;
+
+    return PVDS_SUCCESS;
+}
+
+
 OSCL_EXPORT_REF uint32
 PVMFMemoryBufferWriteDataStreamImpl::QueryBufferingCapacity()
 {
@@ -2191,6 +2236,12 @@
     return iTempCacheCapacity;
 }
 
+OSCL_EXPORT_REF uint32 PVMFMemoryBufferWriteDataStreamImpl::QueryBufferingTrimMargin()
+{
+    LOGTRACE((0, "PVMFMemoryBufferWriteDataStreamImpl::QueryBufferingTrimMargin returning %d", iTempCacheTrimMargin));
+    return iTempCacheTrimMargin;
+}
+
 OSCL_EXPORT_REF PvmiDataStreamStatus
 PVMFMemoryBufferWriteDataStreamImpl::MakePersistent(int32 aOffset, uint32 aSize)
 {
diff --git a/pvmi/pvmf/include/pvmi_data_stream_interface.h b/pvmi/pvmf/include/pvmi_data_stream_interface.h
index 8ee3b74..3163ef7 100644
--- a/pvmi/pvmf/include/pvmi_data_stream_interface.h
+++ b/pvmi/pvmf/include/pvmi_data_stream_interface.h
@@ -426,6 +426,36 @@
         }
 
         /**
+        * @brief Sets the data stream buffering capacity and trim margin.
+        *
+        * Currently, this is only implemented for the Memory Buffer Data
+        * Stream class (MBDS).
+        *
+        * Care should be taken when setting the capacity or trim margin of
+        * the MBDS for progressive playback to not set the capacity or trim
+        * margin higher than the socket node memory pool size.  Otherwise, the
+        * graph could deadlock with the socket node waiting for free memory
+        * fragments while the download manager waits for the MBDS to fill.
+        *
+        * The trim margin is the amount of data behind the read pointer that
+        * is kept in the cache for future reference.  The trim margin is
+        * useful when the data stream reader is randomly accessing the data
+        * stream contents.  If the reader only reads the data stream
+        * sequentially, the trim margin can be set to 0.
+        *
+        * @param[in]  aMinCapacity  Minimum capacity being requested.
+        * @param[in]  aTrimMargin   Amount of stale data to keep cached.
+        *
+        * @return PVDS_NOT_SUPPORTED   if data stream is not an MBDS.
+        *         PVDS_SUCCESS         if successful.
+        */
+        virtual PvmiDataStreamStatus SetBufferingCapacityAndTrimMargin(uint32 aMinCapacity, uint32 aTrimMargin)
+        {
+            //This method is currently only supported by Memory Buffer Data Streams.
+            return PVDS_NOT_SUPPORTED;
+        }
+
+        /**
         * Returns the data stream buffering capacity, if it is a memory buffer data stream (MBDS)
         * Used in progressive playback where MBDS has a finite cache size
         *
@@ -439,6 +469,23 @@
 
 
         /**
+        * @brief Returns the data stream buffering trim margin; the amount of
+        *        "stale" data (data behind the current read position) that is
+        *        kept cached.
+        *
+        * Currently only implemented for Memory Buffer Data Streams (MBDS).
+        *
+        * @return buffering trim margin
+        *
+        */
+        virtual uint32 QueryBufferingTrimMargin()
+        {
+            return 0;
+        }
+
+
+
+        /**
         * Sets the request observer usually in the stream writer
         * Used in progressive playback for repositioning requests, etc
         *