1// Copyright 2013 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef MEDIA_CAST_AUDIO_SENDER_AUDIO_ENCODER_H_ 6#define MEDIA_CAST_AUDIO_SENDER_AUDIO_ENCODER_H_ 7 8#include "base/memory/ref_counted.h" 9#include "base/memory/scoped_ptr.h" 10#include "base/threading/thread_checker.h" 11#include "media/base/audio_bus.h" 12#include "media/cast/cast_config.h" 13#include "media/cast/cast_environment.h" 14 15namespace base { 16class TimeTicks; 17} 18 19namespace media { 20namespace cast { 21 22class AudioEncoder { 23 public: 24 typedef base::Callback<void(scoped_ptr<transport::EncodedFrame>)> 25 FrameEncodedCallback; 26 27 AudioEncoder(const scoped_refptr<CastEnvironment>& cast_environment, 28 const AudioSenderConfig& audio_config, 29 const FrameEncodedCallback& frame_encoded_callback); 30 virtual ~AudioEncoder(); 31 32 CastInitializationStatus InitializationResult() const; 33 34 void InsertAudio(scoped_ptr<AudioBus> audio_bus, 35 const base::TimeTicks& recorded_time); 36 37 private: 38 class ImplBase; 39 class OpusImpl; 40 class Pcm16Impl; 41 42 const scoped_refptr<CastEnvironment> cast_environment_; 43 scoped_refptr<ImplBase> impl_; 44 45 // Used to ensure only one thread invokes InsertAudio(). 46 base::ThreadChecker insert_thread_checker_; 47 48 DISALLOW_COPY_AND_ASSIGN(AudioEncoder); 49}; 50 51} // namespace cast 52} // namespace media 53 54#endif // MEDIA_CAST_AUDIO_SENDER_AUDIO_ENCODER_H_ 55