//-----------------------------------------------------------------------
      void TransportStream::write(
                                  SecureByteBlockPtr bufferToAdopt,
                                  StreamHeaderPtr header
                                  )
      {
        ZS_THROW_INVALID_ARGUMENT_IF(!bufferToAdopt)

        AutoRecursiveLock lock(getLock());

        if (isShutdown()) {
          ZS_LOG_WARNING(Detail, log("cannot write as already shutdown"))
          return;
        }

        if (mBlockQueue) {
          ZS_LOG_TRACE(log("write blocked thus putting buffer into block queue") + ZS_PARAM("size", bufferToAdopt->SizeInBytes()) + ZS_PARAM("header", (bool)header))
          if (!mBlockHeader) {
            mBlockHeader = header;
          }
          if (bufferToAdopt->SizeInBytes() > 0) {
            mBlockQueue->Put(bufferToAdopt->BytePtr(), bufferToAdopt->SizeInBytes());
          }
          return;
        }

        Buffer buffer;
        buffer.mBuffer = bufferToAdopt;
        buffer.mHeader = header;

        ZS_LOG_TRACE(log("buffer written") + ZS_PARAM("written", bufferToAdopt->SizeInBytes()) )

        mBuffers.push_back(buffer);

        notifySubscribers(false, true);
      }
    //-------------------------------------------------------------------------
    void RTPReceiverChannelAudio::onSecureTransportState(ISecureTransport::States state)
    {
      ZS_LOG_TRACE(log("notified secure transport state") + ZS_PARAM("state", ISecureTransport::toString(state)))

      AutoRecursiveLock lock(*this);

      mTransportState = state;

      if (mChannelResource)
        mChannelResource->notifyTransportState(state);
    }
    //-------------------------------------------------------------------------
    void RTPReceiverChannelAudio::onUpdate(ParametersPtr params)
    {
      ZS_LOG_TRACE(log("on update") + params->toDebug())

      UseChannelResourcePtr channelResource;
      {
        AutoRecursiveLock lock(*this);
        mParameters = make_shared<Parameters>(*params);
        channelResource = mChannelResource;
      }

      if (channelResource)
        channelResource->notifyUpdate(params);
    }