chromium/chromecast/media/cma/backend/mixer/post_processors/post_processor_wrapper.h

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROMECAST_MEDIA_CMA_BACKEND_MIXER_POST_PROCESSORS_POST_PROCESSOR_WRAPPER_H_
#define CHROMECAST_MEDIA_CMA_BACKEND_MIXER_POST_PROCESSORS_POST_PROCESSOR_WRAPPER_H_

// Provides a wrapper for AudioPostProcessor to allow using it as an
// AudioPostProcessor2. This works by simply fowarding the input buffer as the
// output buffer, since the original AudioPostProcessor API has equal numbers of
// input and output channels.
//
// Note that AudioPostProcessor is DEPRECATED and support will be dropped
// entirely in the near future.

#include <memory>
#include <string>

#include "chromecast/public/media/audio_post_processor2_shlib.h"

namespace chromecast {
namespace media {

class AudioPostProcessor;

class AudioPostProcessorWrapper : public AudioPostProcessor2 {
 public:
  // AudioPostProcessorWrapper owns |pp|.
  AudioPostProcessorWrapper(std::unique_ptr<AudioPostProcessor> pp,
                            int channels);

  // AudioPostProcessorWrapper does not own |pp|. Calling code is responsible
  // for owning the lifetime of |pp|. This should only be used for testing.
  AudioPostProcessorWrapper(AudioPostProcessor* pp, int channels);

  AudioPostProcessorWrapper(const AudioPostProcessorWrapper&) = delete;
  AudioPostProcessorWrapper& operator=(const AudioPostProcessorWrapper&) =
      delete;

  ~AudioPostProcessorWrapper() override;

 private:
  // AudioPostProcessor2 implementation:
  bool SetConfig(const Config& config) override;
  const Status& GetStatus() override;
  void ProcessFrames(float* data, int frames, Metadata* metadata) override;
  bool UpdateParameters(const std::string& message) override;
  void SetContentType(AudioContentType content_type) override;
  void SetPlayoutChannel(int channel) override;

  std::unique_ptr<AudioPostProcessor> owned_pp_;
  Status status_;
  AudioPostProcessor* pp_;
};

}  // namespace media
}  // namespace chromecast

#endif  // CHROMECAST_MEDIA_CMA_BACKEND_MIXER_POST_PROCESSORS_POST_PROCESSOR_WRAPPER_H_